//
//  Step1ReadingView.m
//  LineByLine
//
//  Created by 병철 김 on 11. 10. 6..
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import "Step1ReadingView.h"
#import "CommonDefine.h"
#import "CoreDataManager.h"


@implementation Step1ReadingView
@synthesize viewDelegate, paragraphs, pageCount;

- (id)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [tableView setFrame:CGRectMake(0, 40, kContentWidth, kReadViewHeight)];
        [tableView setRowHeight:kReadViewHeight];
        
        [self setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"background.png"]]];
        
        UIButton *smartNext = [UIButton buttonWithType:UIButtonTypeCustom];
        [smartNext setFrame:CGRectMake(230, 315, 80, 30)];
        [smartNext setTitle:@"Next >" forState:UIControlStateNormal];
        [smartNext setTitleColor:[UIColor darkGrayColor] forState:UIControlStateNormal];
        [smartNext setTitleShadowColor:[UIColor blackColor] forState:UIControlStateNormal];
        [smartNext setTitleShadowColor:[UIColor clearColor] forState:UIControlStateHighlighted];
        [smartNext.titleLabel setFont:[UIFont boldSystemFontOfSize:20]];
        [smartNext.titleLabel setShadowOffset:CGSizeMake(2, 2)];
        [self addSubview:smartNext];
        
        UIButton *moveUp = [UIButton buttonWithType:UIButtonTypeCustom];
        [moveUp setAlpha:0.12];
        [moveUp setBackgroundImage:[UIImage imageNamed:@"move_up.png"] forState:UIControlStateNormal];
        [moveUp setFrame:CGRectMake(154, 50, 22, 11)];
        [self addSubview:moveUp];
        
        UIButton *moveDown = [UIButton buttonWithType:UIButtonTypeCustom];
        [moveDown setAlpha:0.12];
        [moveDown setBackgroundImage:[UIImage imageNamed:@"move_down.png"] forState:UIControlStateNormal];
        [moveDown setFrame:CGRectMake(154, 340, 22, 11)];
        [self addSubview:moveDown];
        
        UIButton *moveLeft = [UIButton buttonWithType:UIButtonTypeCustom];
        [moveLeft setAlpha:0.12];
        [moveLeft setBackgroundImage:[UIImage imageNamed:@"move_left.png"] forState:UIControlStateNormal];
        [moveLeft setFrame:CGRectMake(10, 190, 11, 22)];
        [self addSubview:moveLeft];
        
        UIButton *moveRight = [UIButton buttonWithType:UIButtonTypeCustom];
        [moveRight setAlpha:0.12];
        [moveRight setBackgroundImage:[UIImage imageNamed:@"move_right.png"] forState:UIControlStateNormal];
        [moveRight setFrame:CGRectMake(299, 190, 11, 22)];
        [self addSubview:moveRight];
        
        progressView = [[RangedProgressView alloc] initWithFrame:CGRectMake(10, 380, 300, 22)];
        [self addSubview:progressView];
        [progressView release];
    }
    return self;
}

- (void) configView {
    [super configView];
    [progressView setParagraphs:paragraphs];
    [progressView setPageCount:pageCount];
    [progressView drawMarkerAt:curPage];
}

- (void) drawProgressViewMarker {
    [progressView drawMarkerAt:curPage];
}

@end
